package model

import (
	"strconv"
	"strings"

	"github.com/zeromicro/go-zero/core/stores/sqlx"
)

var ErrNotFound = sqlx.ErrNotFound

func Ids2Str(ids []int64) string {
	idArry := make([]string, 0)
	for _, id := range ids {
		idArry = append(idArry, strconv.Itoa(int(id)))
	}
	return strings.Join(idArry, ",")
}

func str2Ids(str string) []int64 {
	idArry := strings.Split(str, ",")
	ret := make([]int64, 0)
	for _, idStr := range idArry {
		if id, err := strconv.Atoi(idStr); err == nil {
			ret = append(ret, int64(id))
		}
	}
	return ret
}
